{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider #}
{% set ea = ea() %}
{% extends null != ea ? ea.templatePath('layout') : '@EasyAdmin/page/login_minimal.html.twig' %}
{% trans_default_domain null != ea ? ea.i18n.translationDomain : (translation_domain is defined ? translation_domain ?? 'messages') %}

{% block body_class 'page-login' %}
{% block page_title %}{{ page_title is defined ? page_title|raw : (null != ea ? ea.dashboardTitle|raw : '') }}{% endblock %}

{% block head_favicon %}
    {% if favicon_path|default(false) %}
        <link rel="shortcut icon" href="{{ favicon_path }}">
    {% else %}
        {{ parent() }}
    {% endif %}
{% endblock %}

{% block wrapper_wrapper %}
    {% set page_title = block('page_title') %}
    {% set _username_label = username_label is defined ? username_label|trans : 'login_page.username'|trans({}, 'EasyAdminBundle') %}
    {% set _password_label = password_label is defined ? password_label|trans : 'login_page.password'|trans({}, 'EasyAdminBundle') %}
    {% set _forgot_password_label = forgot_password_label is defined ? forgot_password_label|trans : 'login_page.forgot_password'|trans({}, 'EasyAdminBundle') %}
    {% set _remember_me_label = remember_me_label is defined ? remember_me_label|trans : 'login_page.remember_me'|trans({}, 'EasyAdminBundle') %}
    {% set _sign_in_label = sign_in_label is defined ? sign_in_label|trans : 'login_page.sign_in'|trans({}, 'EasyAdminBundle') %}

    {{ include('@EasyAdmin/flash_messages.html.twig') }}

    <div class="login-wrapper">
        <header class="main-header">
            <div id="header-logo">
                {% block header_logo %}
                    {% if page_title %}
                        {% if null != ea %}
                            <a class="logo {{ page_title|length > 14 ? 'logo-long' }}" title="{{ page_title|striptags }}" href="{{ path(ea.dashboardRouteName) }}">
                                {{ page_title|raw }}
                            </a>
                        {% else %}
                            <div class="logo {{ page_title|length > 14 ? 'logo-long' }}">
                                {{ page_title|raw }}
                            </div>
                        {% endif %}
                    {% endif %}
                {% endblock header_logo %}
            </div>
        </header>

        <section class="content">
            {% if error|default(false) %}
                <div class="w-100 alert alert-danger rounded mb-3">
                    {{ error.messageKey|trans(error.messageData, 'security') }}
                </div>
            {% endif %}

            {% block login_form_wrapper %}
            <form method="post" action="{{ action|default('') }}">
                {% if csrf_token_intention|default(false) %}
                    <input type="hidden" name="_csrf_token" value="{{ csrf_token(csrf_token_intention) }}">
                {% endif %}

                <input type="hidden" name="{{ target_path_parameter|default('_target_path') }}" value="{{ target_path|default(null != ea ? path(ea.dashboardRouteName) : '/') }}" />

                {% block login_form_credentials_wrapper %}
                    <div class="form-group">
                        <label class="form-control-label required" for="username">{{ _username_label }}</label>
                        <div class="form-widget">
                            <input type="text" id="username" name="{{ username_parameter|default('_username') }}" class="form-control" value="{{ last_username|default('') }}" required autofocus autocomplete="username">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="form-control-label required" for="password">{{ _password_label }}</label>
                        <div class="form-widget">
                            <input type="password" id="password" name="{{ password_parameter|default('_password') }}" class="form-control" required autocomplete="current-password">
                        </div>

                        {% if forgot_password_enabled|default(false) %}
                            <div class="form-text">
                                <a href="{{ forgot_password_path|default('#') }}">{{ _forgot_password_label }}</a>
                            </div>
                        {% endif %}
                    </div>
                {% endblock login_form_credentials_wrapper %}

                {% if remember_me_enabled|default(false) %}
                    <div class="form-group">
                        <input class="form-check-input" type="checkbox" id="remember_me" name="{{ remember_me_parameter|default('_remember_me') }}" {{ remember_me_checked|default(false) ? 'checked' }}>
                        <label class="form-check-label" for="remember_me">
                            {{ _remember_me_label }}
                        </label>
                    </div>
                {% endif %}

                <twig:ea:Button type="submit" variant="primary" size="lg" isBlock htmlAttributes="{class: 'btn-block'}">{{ _sign_in_label }}</twig:ea:Button>
            </form>

            <script src="{{ asset('login.js', constant('EasyCorp\\Bundle\\EasyAdminBundle\\Asset\\AssetPackage::PACKAGE_NAME')) }}"></script>
            {% endblock login_form_wrapper %}
        </section>
    </div>
{% endblock %}
